--添加专属的消耗配方
do
    CHARACTER_INGREDIENT.BAIZEALER_STARNESS = "decrease_starness"
    local oldIsCharacterIngredient = GLOBAL.IsCharacterIngredient
    function GLOBAL.IsCharacterIngredient(ingredienttype, ...)
        if CHARACTER_INGREDIENT.BAIZEALER_STARNESS == ingredienttype then
            return true
        end
        return oldIsCharacterIngredient(ingredienttype, ...)
    end

    do
        local builder_replica = require "components/builder_replica"
        local oldHasCharacterIngredient = builder_replica.HasCharacterIngredient
        function builder_replica:HasCharacterIngredient(ingredient, ...)
            if self.inst.components.builder ~= nil then
            elseif self.classified ~= nil then
                if ingredient.type == CHARACTER_INGREDIENT.BAIZEALER_STARNESS then
                    local starnum = self.inst.GetStarness and self.inst:GetStarness()
                    if starnum then
                        return starnum >= ingredient.amount, starnum
                    end
                end
            end
            return oldHasCharacterIngredient(self, ingredient, ...)
        end
    end
    do
        local builder = require "components/builder"
        local oldHasCharacterIngredient = builder.HasCharacterIngredient
        function builder:HasCharacterIngredient(ingredient, ...)
            if ingredient.type == CHARACTER_INGREDIENT.BAIZEALER_STARNESS then
                local starnum = self.inst and self.inst.player_classified.currentstarness and
                    self.inst.player_classified.currentstarness:value()
                if starnum then
                    return starnum >= ingredient.amount, starnum
                end
            end
            return oldHasCharacterIngredient(self, ingredient, ...)
        end

        local oldRemoveIngredients = builder.RemoveIngredients
        function builder:RemoveIngredients(ingredients, recname, discounted, ...)
            if not self.freebuildmode then
                local recipe = AllRecipes[recname]
                if recipe then
                    for k, v in pairs(recipe.character_ingredients) do
                        if v.type == CHARACTER_INGREDIENT.BAIZEALER_STARNESS
                            and self.inst.components.starness then
                            self.inst.components.starness:DoDelta(-v.amount)
                        end
                    end
                end
            end

            return oldRemoveIngredients(self, ingredients, recname, discounted, ...)
        end
    end
end